home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / awt / TrayIcon.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  6.4 KB  |  320 lines

  1. package java.awt;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.MouseEvent;
  6. import java.awt.event.MouseListener;
  7. import java.awt.event.MouseMotionListener;
  8. import java.awt.peer.TrayIconPeer;
  9. import java.util.EventListener;
  10. import sun.awt.AppContext;
  11. import sun.awt.SunToolkit;
  12.  
  13. public class TrayIcon {
  14.    private Image image;
  15.    private String tooltip;
  16.    private PopupMenu popup;
  17.    private boolean autosize;
  18.    // $FF: renamed from: id int
  19.    private int field_0;
  20.    private String actionCommand;
  21.    private transient TrayIconPeer peer;
  22.    transient MouseListener mouseListener;
  23.    transient MouseMotionListener mouseMotionListener;
  24.    transient ActionListener actionListener;
  25.    private transient Object privateKey;
  26.  
  27.    private TrayIcon() throws UnsupportedOperationException, HeadlessException, SecurityException {
  28.       this.privateKey = new Object();
  29.       SystemTray.checkSystemTrayAllowed();
  30.       if (GraphicsEnvironment.isHeadless()) {
  31.          throw new HeadlessException();
  32.       } else if (!SystemTray.isSupported()) {
  33.          throw new UnsupportedOperationException();
  34.       } else {
  35.          SunToolkit.insertTargetMapping(this, AppContext.getAppContext());
  36.       }
  37.    }
  38.  
  39.    public TrayIcon(Image var1) {
  40.       this();
  41.       if (var1 == null) {
  42.          throw new IllegalArgumentException("creating TrayIcon with null Image");
  43.       } else {
  44.          this.setImage(var1);
  45.       }
  46.    }
  47.  
  48.    public TrayIcon(Image var1, String var2) {
  49.       this(var1);
  50.       this.setToolTip(var2);
  51.    }
  52.  
  53.    public TrayIcon(Image var1, String var2, PopupMenu var3) {
  54.       this(var1, var2);
  55.       this.setPopupMenu(var3);
  56.    }
  57.  
  58.    public void setImage(Image var1) {
  59.       if (var1 == null) {
  60.          throw new NullPointerException("setting null Image");
  61.       } else {
  62.          this.image = var1;
  63.          TrayIconPeer var2 = this.peer;
  64.          if (var2 != null) {
  65.             var2.updateImage();
  66.          }
  67.  
  68.       }
  69.    }
  70.  
  71.    public Image getImage() {
  72.       return this.image;
  73.    }
  74.  
  75.    public void setPopupMenu(PopupMenu var1) {
  76.       if (var1 != this.popup) {
  77.          synchronized(TrayIcon.class) {
  78.             if (var1 != null) {
  79.                if (var1.isTrayIconPopup) {
  80.                   throw new IllegalArgumentException("the PopupMenu is already set for another TrayIcon");
  81.                }
  82.  
  83.                var1.isTrayIconPopup = true;
  84.             }
  85.  
  86.             if (this.popup != null) {
  87.                this.popup.isTrayIconPopup = false;
  88.             }
  89.  
  90.             this.popup = var1;
  91.          }
  92.       }
  93.    }
  94.  
  95.    public PopupMenu getPopupMenu() {
  96.       return this.popup;
  97.    }
  98.  
  99.    public void setToolTip(String var1) {
  100.       this.tooltip = var1;
  101.       TrayIconPeer var2 = this.peer;
  102.       if (var2 != null) {
  103.          var2.setToolTip(var1);
  104.       }
  105.  
  106.    }
  107.  
  108.    public String getToolTip() {
  109.       return this.tooltip;
  110.    }
  111.  
  112.    public void setImageAutoSize(boolean var1) {
  113.       this.autosize = var1;
  114.       TrayIconPeer var2 = this.peer;
  115.       if (var2 != null) {
  116.          var2.updateImage();
  117.       }
  118.  
  119.    }
  120.  
  121.    public boolean isImageAutoSize() {
  122.       return this.autosize;
  123.    }
  124.  
  125.    public synchronized void addMouseListener(MouseListener var1) {
  126.       if (var1 != null) {
  127.          this.mouseListener = AWTEventMulticaster.add(this.mouseListener, var1);
  128.       }
  129.    }
  130.  
  131.    public synchronized void removeMouseListener(MouseListener var1) {
  132.       if (var1 != null) {
  133.          this.mouseListener = AWTEventMulticaster.remove(this.mouseListener, var1);
  134.       }
  135.    }
  136.  
  137.    public synchronized MouseListener[] getMouseListeners() {
  138.       return (MouseListener[])this.getListeners(MouseListener.class);
  139.    }
  140.  
  141.    public synchronized void addMouseMotionListener(MouseMotionListener var1) {
  142.       if (var1 != null) {
  143.          this.mouseMotionListener = AWTEventMulticaster.add(this.mouseMotionListener, var1);
  144.       }
  145.    }
  146.  
  147.    public synchronized void removeMouseMotionListener(MouseMotionListener var1) {
  148.       if (var1 != null) {
  149.          this.mouseMotionListener = AWTEventMulticaster.remove(this.mouseMotionListener, var1);
  150.       }
  151.    }
  152.  
  153.    public synchronized MouseMotionListener[] getMouseMotionListeners() {
  154.       return (MouseMotionListener[])this.getListeners(MouseMotionListener.class);
  155.    }
  156.  
  157.    public String getActionCommand() {
  158.       return this.actionCommand;
  159.    }
  160.  
  161.    public void setActionCommand(String var1) {
  162.       this.actionCommand = var1;
  163.    }
  164.  
  165.    public synchronized void addActionListener(ActionListener var1) {
  166.       if (var1 != null) {
  167.          this.actionListener = AWTEventMulticaster.add(this.actionListener, var1);
  168.       }
  169.    }
  170.  
  171.    public synchronized void removeActionListener(ActionListener var1) {
  172.       if (var1 != null) {
  173.          this.actionListener = AWTEventMulticaster.remove(this.actionListener, var1);
  174.       }
  175.    }
  176.  
  177.    public synchronized ActionListener[] getActionListeners() {
  178.       return (ActionListener[])this.getListeners(ActionListener.class);
  179.    }
  180.  
  181.    public void displayMessage(String var1, String var2, MessageType var3) {
  182.       if (var1 == null && var2 == null) {
  183.          throw new NullPointerException("displaying the message with both caption and text being null");
  184.       } else {
  185.          TrayIconPeer var4 = this.peer;
  186.          if (var4 != null) {
  187.             var4.displayMessage(var1, var2, var3.toString());
  188.          }
  189.  
  190.       }
  191.    }
  192.  
  193.    public Dimension getSize() {
  194.       return SystemTray.getSystemTray().getTrayIconSize();
  195.    }
  196.  
  197.    <T extends EventListener> T[] getListeners(Class<T> var1) {
  198.       Object var2 = null;
  199.       if (var1 == MouseListener.class) {
  200.          var2 = this.mouseListener;
  201.       } else if (var1 == MouseMotionListener.class) {
  202.          var2 = this.mouseMotionListener;
  203.       } else if (var1 == ActionListener.class) {
  204.          var2 = this.actionListener;
  205.       }
  206.  
  207.       return (T[])AWTEventMulticaster.getListeners((EventListener)var2, var1);
  208.    }
  209.  
  210.    void addNotify() throws AWTException {
  211.       synchronized(this) {
  212.          if (this.peer == null) {
  213.             this.peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createTrayIcon(this);
  214.          }
  215.       }
  216.  
  217.       this.peer.setToolTip(this.tooltip);
  218.    }
  219.  
  220.    void removeNotify() {
  221.       Object var1 = null;
  222.       TrayIconPeer var5;
  223.       synchronized(this) {
  224.          var5 = this.peer;
  225.          this.peer = null;
  226.       }
  227.  
  228.       if (var5 != null) {
  229.          var5.dispose();
  230.       }
  231.  
  232.    }
  233.  
  234.    void setID(int var1) {
  235.       this.field_0 = var1;
  236.    }
  237.  
  238.    int getID() {
  239.       return this.field_0;
  240.    }
  241.  
  242.    void dispatchEvent(AWTEvent var1) {
  243.       EventQueue.setCurrentEventAndMostRecentTime(var1);
  244.       Toolkit.getDefaultToolkit().notifyAWTEventListeners(var1);
  245.       this.processEvent(var1);
  246.    }
  247.  
  248.    void processEvent(AWTEvent var1) {
  249.       if (var1 instanceof MouseEvent) {
  250.          switch (var1.getID()) {
  251.             case 500:
  252.             case 501:
  253.             case 502:
  254.                this.processMouseEvent((MouseEvent)var1);
  255.                break;
  256.             case 503:
  257.                this.processMouseMotionEvent((MouseEvent)var1);
  258.                break;
  259.             default:
  260.                return;
  261.          }
  262.       } else if (var1 instanceof ActionEvent) {
  263.          this.processActionEvent((ActionEvent)var1);
  264.       }
  265.  
  266.    }
  267.  
  268.    void processMouseEvent(MouseEvent var1) {
  269.       MouseListener var2 = this.mouseListener;
  270.       TrayIconPeer var3 = this.peer;
  271.       if (var1.isPopupTrigger() && var3 != null) {
  272.          var3.showPopupMenu(var1.getPoint().x, var1.getPoint().y);
  273.       }
  274.  
  275.       if (var2 != null) {
  276.          int var4 = var1.getID();
  277.          switch (var4) {
  278.             case 500:
  279.                var2.mouseClicked(var1);
  280.                break;
  281.             case 501:
  282.                var2.mousePressed(var1);
  283.                break;
  284.             case 502:
  285.                var2.mouseReleased(var1);
  286.                break;
  287.             default:
  288.                return;
  289.          }
  290.       }
  291.  
  292.    }
  293.  
  294.    void processMouseMotionEvent(MouseEvent var1) {
  295.       MouseMotionListener var2 = this.mouseMotionListener;
  296.       if (var2 != null && var1.getID() == 503) {
  297.          var2.mouseMoved(var1);
  298.       }
  299.  
  300.    }
  301.  
  302.    void processActionEvent(ActionEvent var1) {
  303.       ActionListener var2 = this.actionListener;
  304.       if (var2 != null) {
  305.          var2.actionPerformed(var1);
  306.       }
  307.  
  308.    }
  309.  
  310.    private static native void initIDs();
  311.  
  312.    static {
  313.       Toolkit.loadLibraries();
  314.       if (!GraphicsEnvironment.isHeadless()) {
  315.          initIDs();
  316.       }
  317.  
  318.    }
  319. }
  320.